home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Examples / robotStuff / boringBot.wwModel / model.eve < prev    next >
Encoding:
Text File  |  1995-03-22  |  12.7 KB  |  441 lines

  1. source $modelPath/initialDefines.eve
  2.  
  3.  
  4. #
  5. # all measurements are in feet
  6. #
  7. proc declareShaderAttributes {} {
  8.  
  9.   ### plastic shader stuff
  10.   Declare "Ks" "float"
  11.   Declare "Kd" "float"
  12.   Declare "Ka" "float"
  13.   Declare "roughness" "float"
  14.   Declare "specularcolor" "color"
  15.  
  16.   ### VGBlisteredPaintedMetal shader stuff
  17.   Declare "Name" "string"
  18.   Declare "MetalColor" "color"
  19.   Declare "Age" "float"
  20.   Declare "HeightScale" "float"
  21.   Declare "Ambient" "float"
  22.   Declare "Gloss" "float"
  23.   Declare "Specular" "float"
  24.   Declare "Roughness" "float"
  25.   Declare "Displacement" "string"
  26.   Declare "Origin" "point"
  27.   Declare "UpVector" "point"
  28.   Declare "AtVector" "point"
  29.   Declare "Unit" "string"
  30.   Declare "Scale" "float"
  31.   Declare "AntiAlias" "float"
  32.  
  33. }
  34.  
  35. proc buildSphereHead {{xOrigin 0.0} {yOrigin 0.0} {zOrigin 0.0}} {
  36.   global nodAngle shakeAngle
  37.   global kindOfHead headRadius eyeRadius eyeProtrusion
  38.   global pupilRadius pupilScale 
  39.   global noseLength noseWidth 
  40.   global initialEyeYaw initialEyePitch
  41.   global eyeYaw eyePitch eyeRoll
  42.   global eyeScale
  43.   global headColor eyeColor pupilColor noseColor
  44.   
  45.  
  46.   ##########
  47.   startShape Neck
  48.     ApplyToCTM {Translate $xOrigin $yOrigin $zOrigin}
  49.     ApplyToCTM {Rotate 90 1 0 0}
  50.     Cylinder [expr {$headRadius/3.0}] 0  [expr {2*$headRadius}] 360 
  51.   endShape
  52.  
  53.  
  54.   startShape Head 
  55.     ApplyToCTM {Translate $xOrigin $yOrigin $zOrigin}
  56.     #EveCmd {Color $headColor}
  57.     EveCmd {Rotate $nodAngle 1 0 0 }
  58.     EveCmd {Rotate $shakeAngle 0 1 0 }
  59.     Sphere $headRadius [expr {-$headRadius}] $headRadius 360 
  60.  
  61.     ##########
  62.     startShape LeftEye
  63.       #Surface plastic
  64.       EveCmd {Rotate $initialEyeYaw 1 0 0}
  65.       EveCmd {Rotate $initialEyePitch 0 1 0}
  66.       EveCmd {Translate 0 \
  67.                         [expr {$headRadius*sin([dToR $initialEyeYaw])}] \
  68.                         [expr {-$eyeProtrusion*$headRadius*cos([dToR $initialEyeYaw])}]}
  69.       ##########
  70.       startShape EyeBall
  71.         EveCmd {Scale $eyeScale $eyeScale $eyeScale}
  72.         EveCmd {Rotate $eyeYaw 1 0 0}
  73.         EveCmd {Rotate $eyePitch 0 1 0}
  74.         EveCmd {Rotate $eyeRoll 0 0 1}
  75.         #EveCmd {Color $eyeColor}
  76.         Sphere $eyeRadius [expr {-$eyeRadius}] $eyeRadius 360 
  77.         ##########
  78.         startShape Pupil
  79.           set xTrans 0.0
  80.           set yTrans 0.0
  81.           set zTrans [expr {-$eyeRadius*.7}]
  82.           ApplyToCTM {Translate $xTrans $yTrans $zTrans}
  83.           EveCmd {Scale $pupilScale $pupilScale $pupilScale}
  84.           EveCmd {Color $pupilColor}
  85.           Sphere $pupilRadius [expr {-$pupilRadius}] $pupilRadius 360 
  86.         endShape ;#Pupil
  87.       endShape ;#EyeBall
  88.     endShape ;#LeftEye
  89.  
  90.     ##########
  91.     startShape RightEye
  92.       #Surface plastic
  93.       EveCmd {Rotate $initialEyeYaw 1 0 0}
  94.       EveCmd {Rotate -$initialEyePitch 0 1 0}
  95.       EveCmd {Translate 0 \
  96.                         [expr {$headRadius*sin([dToR $initialEyeYaw])}] \
  97.                         [expr {-$eyeProtrusion*$headRadius*cos([dToR $initialEyeYaw])}]}
  98.       ##########
  99.       startShape EyeBall
  100.         EveCmd {Scale $eyeScale $eyeScale $eyeScale}
  101.         EveCmd {Rotate $eyeYaw 1 0 0}
  102.         EveCmd {Rotate $eyePitch 0 1 0}
  103.         EveCmd {Rotate $eyeRoll 0 0 1}
  104.         #EveCmd {Color $eyeColor}
  105.         Sphere $eyeRadius [expr {-$eyeRadius}] $eyeRadius 360 
  106.         ##########
  107.         startShape Pupil
  108.           set xTrans 0.0
  109.           set yTrans 0.0
  110.           set zTrans [expr {-$eyeRadius*.7}]
  111.           ApplyToCTM {Translate $xTrans $yTrans $zTrans}
  112.           EveCmd {Scale $pupilScale $pupilScale $pupilScale}
  113.           EveCmd {Color $pupilColor}
  114.           Sphere $pupilRadius [expr {-$pupilRadius}] $pupilRadius 360 
  115.         endShape ;#Pupil
  116.       endShape ;#EyeBall
  117.     endShape ;#RightEye
  118.  
  119.     ##########
  120.     startShape Nose
  121.       set tenDegreesInRadians [dToR 10.0]
  122.       set xTrans 0.0
  123.       set yTrans [expr {$headRadius*sin($tenDegreesInRadians)}]
  124.       set zTrans [expr {.8*-$headRadius}]
  125.       ApplyToCTM {Translate $xTrans $yTrans $zTrans}
  126.       ApplyToCTM {Rotate 180.0 1 0 0}
  127.       #EveCmd {Color $noseColor}
  128.       Cone $noseLength $noseWidth 360
  129.     endShape ;#Nose
  130.  
  131.     ##########
  132.     if {[string match martian* $kindOfHead]} { buildAntenna } {}
  133.     if {[string match punk* $kindOfHead]} { buildCrest } {}
  134.  
  135.   endShape ;#Head
  136. }
  137.  
  138.  
  139. proc buildCrest {} {
  140.   global crestCount crestLength crestWidth crestColor crestYawStep
  141.  
  142.   ##########
  143.   startShape Crest
  144.     #EveCmd {Color $crestColor}
  145.     Rotate -110 1 0 0
  146.  
  147.     ##########
  148.     startShape LeftRow
  149.       ApplyToCTM {Rotate -30  0 0 1}
  150.       for {set i 0} {$i < $crestCount} {incr i} \
  151.       {  EveCmd {Cone $crestLength $crestWidth 360}
  152.          EveCmd {Rotate $crestYawStep 1 0 0}
  153.       }
  154.     endShape ;#LeftRow
  155.  
  156.     ##########
  157.     startShape MiddleRow
  158.       for {set i 0} {$i < $crestCount} {incr i} \
  159.       {  EveCmd {Cone $crestLength $crestWidth 360}
  160.          EveCmd {Rotate $crestYawStep 1 0 0}
  161.       }
  162.     endShape ;#MiddleRow
  163.  
  164.     ##########
  165.     startShape RightRow
  166.       ApplyToCTM {Rotate 30  0 0 1}
  167.       for {set i 0} {$i < $crestCount} {incr i} \
  168.       {  EveCmd {Cone $crestLength $crestWidth 360}
  169.          EveCmd {Rotate $crestYawStep 1 0 0}
  170.       }
  171.     endShape ;#RightRow
  172.   endShape ;#Crest
  173. }
  174.  
  175. proc buildAntenna {} {
  176.   global antennaColor antennaRadius antennaTilt antennaLength antennaKnobColor antennaKnobRadius 
  177.  
  178.  
  179.   startShape Antenna
  180.     #EveCmd {Color $antennaColor}
  181.     ApplyToCTM {Rotate -90 1 0 0}
  182.  
  183.     ##########
  184.     startShape LeftShaft
  185.       EveCmd {Rotate -$antennaTilt  0 1 0}
  186.       EveCmd {Cylinder $antennaRadius 0 $antennaLength 360}
  187.  
  188.       ##########
  189.       startShape Knob
  190.         #EveCmd {Color $antennaKnobColor}
  191.         EveCmd {Translate 0 0 $antennaLength}
  192.         EveCmd {Sphere $antennaKnobRadius -$antennaKnobRadius $antennaKnobRadius 360}
  193.       endShape ;#Knob 
  194.     endShape ;#LeftShaft
  195.  
  196.     ##########
  197.     startShape RightShaft
  198.       EveCmd {Rotate $antennaTilt  0 1 0}
  199.       EveCmd {Cylinder $antennaRadius 0 $antennaLength 360}
  200.  
  201.       ##########
  202.       startShape Knob
  203.         #EveCmd {Color $antennaKnobColor}
  204.         EveCmd {Translate 0 0 $antennaLength}
  205.         EveCmd {Sphere $antennaKnobRadius -$antennaKnobRadius $antennaKnobRadius 360}
  206.       endShape ;#Knob 
  207.     endShape ;#LeftShaft
  208.   endShape ;#Antenna
  209. }
  210.  
  211. set kindOfTorso Blistered.5
  212. set torsoXScale 1
  213. set torsoYScale 1.55
  214. set torsoZScale 1
  215. set torsoRadius .4
  216. set torsoColor {.391522 .378109 1}
  217. set torsoSurfaceAge .5
  218.  
  219. proc buildSphereTorso {{xOrigin 0.0} {yOrigin 0.0} {zOrigin 0.0}} {
  220.   global torsoXScale torsoYScale torsoZScale
  221.   global torsoRadius torsoColor
  222.   global torsoSurfaceAge
  223.  
  224.  
  225.   Declare "Age" "float"
  226.   Declare "HeightScale" "float"
  227.   Declare "Gloss" "float"
  228.   Declare "Roughness" "float"
  229.   Declare "Displacement" "string"
  230.  
  231.   startShape Torso 
  232.     ApplyToCTM {Translate $xOrigin $yOrigin $zOrigin}
  233.     #EveCmd {Color $torsoColor}
  234.     EveCmd {Scale $torsoXScale $torsoYScale $torsoZScale} 
  235.     # need to think about this... 
  236.     #Surface VGBlisteredPaintedMetal Age $torsoSurfaceAge HeightScale 5 Gloss 1 Roughness 1 Displacement 1
  237.     EveCmd {Sphere $torsoRadius [expr {-$torsoRadius}] $torsoRadius 360 }
  238.   endShape ;#Torso
  239. }
  240.  
  241.  
  242. set armColor {.7 1 .7}
  243.  
  244. set shoulderRadius [expr 6.0*$headRadius/8.0]
  245. set upperArmRadius [expr $headRadius/2]
  246. set leftUpperArmRotate 0.0
  247. set rightUpperArmRotate 0.0
  248.  
  249. set elbowRadius [expr $shoulderRadius*.7]
  250. set foreArmRadius [expr $upperArmRadius*.8]
  251. set leftForeArmRotate 0.0
  252. set rightForeArmRotate 0.0
  253.  
  254.  
  255. proc buildSphereArm {{side Left} {xOrigin 0.0} {yOrigin 0.0} {zOrigin 0.0}} {
  256.   global shoulderRadius armColor
  257.   global upperArmRadius leftUpperArmRotate rightUpperArmRotate
  258.   global elbowRadius 
  259.   global foreArmRadius leftForeArmRotate rightForeArmRotate 
  260.  
  261.  
  262.   startShape ${side}Arm 
  263.     ApplyToCTM {Translate $xOrigin $yOrigin $zOrigin}
  264.     ApplyToCTM {Rotate 90 0 1 0}
  265.     ApplyToCTM {Rotate 90 1 0 0}
  266.     #EveCmd {Color $armColor}
  267.  
  268.     ##########
  269.     startShape Shoulder
  270.       Sphere $shoulderRadius [expr {-$shoulderRadius}] $shoulderRadius 360 
  271.  
  272.       ##########
  273.       startShape UpperArm
  274.         set upperArmYScale 4.0
  275.         set upperArmLength [expr {$upperArmRadius*$upperArmYScale}]
  276.         set yTrans [expr {$upperArmLength + [expr {$shoulderRadius/2.0}]}]
  277.  
  278.         ApplyToCTM {Rotate 90 0 0 1}
  279.         if {[string compare Left $side]} \
  280.         {} \
  281.         {  set leftUpperArmRotate 45.0;
  282.            EveCmd {Rotate $leftUpperArmRotate 0 1 0}
  283.         }
  284.         if {[string compare Right $side]} \
  285.         {} \
  286.         {  set rightUpperArmRotate -45.0;
  287.            EveCmd {Rotate $rightUpperArmRotate 0 1 0}
  288.         }
  289.         set varName ${side}UpperArmRotate
  290.         
  291.         Cylinder $upperArmRadius 0 $upperArmLength 360
  292.  
  293.         ##########
  294.         startShape Elbow
  295.           ApplyToCTM {Translate 0 0 $upperArmLength}
  296.           Sphere $elbowRadius [expr {-$elbowRadius}] $elbowRadius 360 
  297.  
  298.           ##########
  299.           startShape foreArm
  300.             set foreArmLength [expr {$upperArmLength*1.2}]
  301.             set yTrans [expr {$foreArmLength + [expr {$elbowRadius/2.0}]}]
  302.  
  303.             if {[string compare Left $side]} \
  304.             {} \
  305.             {  set leftForeArmRotate -65.0;
  306.             EveCmd {Rotate $leftForeArmRotate 0 1 0}
  307.             }
  308.             if {[string compare Right $side]} \
  309.             {} \
  310.             {  set rightForeArmRotate 65.0;
  311.                EveCmd {Rotate $rightForeArmRotate 0 1 0}
  312.             }
  313.             Cylinder $foreArmRadius 0 $foreArmLength 360
  314.           endShape ;# foreArm
  315.         endShape ;# Elbow
  316.       endShape ;#UpperArm
  317.     endShape ;#Shoulder
  318.   endShape ;#Arm
  319. }
  320.  
  321. proc buildRobot {} {
  322.   global kindOfHead headRadius initialEyePitch eyeScale antennaRadius antennaLength
  323.   global kindOfTorso torsoRadius torsoYScale torsoSurfaceAge
  324.   global fork tire gasket surface topOfFork hubcap piston
  325.   global xR yR zR xT yT zT xS yS zS modelPath
  326.  
  327.  
  328.   if {[string compare $kindOfHead fish]} \
  329.   {} \
  330.   { set initialEyePitch 45; 
  331.     set eyeScale 2; 
  332.   }
  333.  
  334.   if {[string compare $kindOfHead insect]} \
  335.   {} \
  336.   { set initialEyePitch 80; 
  337.     set eyeScale 3; 
  338.   }
  339.  
  340.   if {[string compare $kindOfHead martianFish]} \
  341.   {} \
  342.   { set initialEyePitch 45; 
  343.     set eyeScale 2; 
  344.   }
  345.  
  346.   if {[string compare $kindOfHead martianInsect]} \
  347.   {} \
  348.   { set initialEyePitch 80; 
  349.     set eyeScale 3; 
  350.     set antennaRadius 0.01; 
  351.     set antennaLength 0.7; 
  352.   }
  353.  
  354.   if {[string compare $kindOfHead punkFish]} \
  355.   {} \
  356.   { set initialEyePitch 45; 
  357.     set eyeScale 2; 
  358.   }
  359.  
  360.   if {[string compare $kindOfHead punkInsect]} \
  361.   {} \
  362.   { set initialEyePitch 80; 
  363.     set eyeScale 3; 
  364.   }
  365.  
  366.   if {[string compare $kindOfTorso Blistered.1]} \
  367.   {} \
  368.   { set torsoSurfaceAge .1
  369.   }
  370.   if {[string compare $kindOfTorso Blistered.2]} \
  371.   {} \
  372.   { set torsoSurfaceAge .2
  373.   }
  374.   if {[string compare $kindOfTorso Blistered.3]} \
  375.   {} \
  376.   { set torsoSurfaceAge .3
  377.   }
  378.   if {[string compare $kindOfTorso Blistered.4]} \
  379.   {} \
  380.   { set torsoSurfaceAge .4
  381.   }
  382.   if {[string compare $kindOfTorso Blistered.5]} \
  383.   {} \
  384.   { set torsoSurfaceAge .5
  385.   }
  386.   if {[string compare $kindOfTorso Blistered.5]} \
  387.   {} \
  388.   { set torsoSurfaceAge .5
  389.   }
  390.   if {[string compare $kindOfTorso Blistered.6]} \
  391.   {} \
  392.   { set torsoSurfaceAge .6
  393.   }
  394.   if {[string compare $kindOfTorso Blistered.7]} \
  395.   {} \
  396.   { set torsoSurfaceAge .7
  397.   }
  398.   if {[string compare $kindOfTorso Blistered.8]} \
  399.   {} \
  400.   { set torsoSurfaceAge .8
  401.   }
  402.  
  403.   startShape Robot
  404.     declareShaderAttributes
  405.     source $modelPath/support.eve
  406.     buildSphereTorso
  407.     buildSphereHead 0 [expr {1.2 * $headRadius + [expr {$torsoRadius * $torsoYScale}]}] 0
  408.     buildSphereArm Left [expr {$torsoRadius * .9}] [expr {.7 * $torsoRadius * $torsoYScale}] 0
  409.     buildSphereArm Right -[expr {$torsoRadius * .9}] [expr {.7 * $torsoRadius * $torsoYScale}] 0
  410.   endShape
  411. }
  412.  
  413. proc nod {{howManySteps 4} {nodIncrement 10}} {
  414.   global nodAngle
  415.  
  416.  
  417.   # lift up a bit, then nod twice, then settle back to original angle
  418.   set nodAngle [expr {$nodAngle+$nodIncrement}]; updateView
  419.   for {set i 0} {$i < $howManySteps} {incr i} {set nodAngle [expr {$nodAngle-$nodIncrement}]; updateView}
  420.   for {set i 0} {$i < $howManySteps} {incr i} {set nodAngle [expr {$nodAngle+$nodIncrement}]; updateView}
  421.   for {set i 0} {$i < $howManySteps} {incr i} {set nodAngle [expr {$nodAngle-$nodIncrement}]; updateView}
  422.   for {set i 0} {$i < $howManySteps} {incr i} {set nodAngle [expr {$nodAngle+$nodIncrement}]; updateView}
  423.   set nodAngle [expr {$nodAngle-$nodIncrement}]; updateView
  424. }
  425.  
  426. proc shake {{howManySteps 4} {shakeIncrement 10}} {
  427.   global shakeAngle
  428.  
  429.  
  430.   for {set i 0} {$i < $howManySteps} {incr i} {set shakeAngle [expr {$shakeAngle+$shakeIncrement}]; updateView}
  431.   for {set i 0} {$i < $howManySteps} {incr i} {set shakeAngle [expr {$shakeAngle-$shakeIncrement}]; updateView}
  432.   for {set i 0} {$i < $howManySteps} {incr i} {set shakeAngle [expr {$shakeAngle+$shakeIncrement}]; updateView}
  433.   for {set i 0} {$i < $howManySteps} {incr i} {set shakeAngle [expr {$shakeAngle-$shakeIncrement}]; updateView}
  434. }
  435.  
  436.  
  437. set kindOfHead punkInsect
  438.  
  439. buildRobot
  440.  
  441.